<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<title></title>
</head>
<body>
<script type="text/javascript">
var Global = require('global');
var support = 'postMessage' in Global;
var allowDomain = /\./;
//var allowDomain = /(?:^|\.)(?:made-in-china|micstatic)\.com(?:\/|:|$)/;

var ajax = function(url, callback){
	var xhr = new XMLHttpRequest();
	xhr.open('GET', url);
	xhr.onreadystatechange = function(e){
		if(xhr.status == 200 && xhr.readyState === 4){
			(typeof callback === 'function') && callback(xhr.responseText);
		}
	};
	
	xhr.send(null);
};

if(support){
	// receive require src
	Global.addEventListener('message', function(e){
		if(e.data){
			try{
				var data = JSON.parse(e.data);
				
				if(allowDomain.test(data.client)){
					ajax(data.src, function(script){
						e.source.postMessage(JSON.stringify({
							script: script,
							src: data.src,
							server: Global.location.href,
							stamp: new Date().valueOf()
						}), '*');
					});
				}
			}catch(ex){}
		}
	}, false);
}
</script>
</body>
</html>